<?php
	
	
	class xl_nguoi_dung extends database
	{
		/*khánh*/
		function checkOldpass($old){
			$this->setQuerry("select * from nguoidung where MatKhau='".md5($old)."'");
			$result = $this->loadAllRow();
			return count($result);
		}
		function newPass($newpass,$id){
			$this->setQuerry("update nguoidung set MatKhau='".md5($newpass)."' where MaNguoiDung='".$id."'");
			$result=$this->querry();
			return $result;
		}
		function resetPass($matkhau,$email)
		{
			$this->setQuerry("update nguoidung set MatKhau='".md5($matkhau)."' where Email='".$email."'");
			$result=$this->querry();
			return $result;
		}
		function kiemTraDangNhap($email,$pass){
			$this->setQuerry("select * from nguoidung where Email = '".$email."' and MatKhau = '".md5($pass)."'");
			$result = $this->loadAllRow();
			return $result;
		}
		function layNguoiDungTheoEmail($email){
			$this->setQuerry("select * from nguoidung where Email = '".$email."'");
			$result = $this->loadAllRow();
			return $result;
		}
		function layNguoiDungTheoChuoiXacNhan($chuoi){
			$this->setQuerry("select * from nguoidung where ChuoiXacNhan = '".$chuoi."'");
			$result = $this->loadAllRow();
			return $result;
		}
		function kichHoatTaiKhoanNguoiDung($id){
			$this->setQuerry("update nguoidung set KickHoat = 1 where MaNguoiDung='".$id."'");
			$result=$this->querry();
			return $result;
		}
		function layNguoiDung($id){
			$this->setQuerry("select * from nguoidung where MaNguoiDung = '".$id."'");
			$result = $this->loadAllRow();
			return $result;
		}
		/*end*/
		
		// cập nhật ảnh
		function xoaAnhNguoiDung($manguoidung)
		{
			$this->setQuerry("update nguoidung set HinhAnhDaiDien='' where MaNguoiDung=".$manguoidung);
			$result=$this->querry();
			return $result;
		}
		
		function themAnhNguoiDung($manguoidung,$tenanh)
		{
			$this->setQuerry("update nguoidung set HinhAnhDaiDien='".$tenanh."' where MaNguoiDung=".$manguoidung);
			$result=$this->querry();
			return $result;
		}
		//end
		function danhSachNguoiDung()
		{
			$this->setQuerry('select * from nguoidung');
			$result = $this->loadAllRow();
			return $result;
		}
		function themNguoiDung($tenhienthi,$matkhau,$email,$chuoixacnhan)
		{
			$this->setQuerry("insert into nguoidung (TenHienThi,MatKhau,Email,ChuoiXacNhan) values ('".$tenhienthi."','".$matkhau."','".$email."','".$chuoixacnhan."')");
			$result=$this->querry();
			return $result;
		}
		function capNhatTenNguoiDung($manguoidung,$tenhienthi)
		{
			$this->setQuerry("update nguoidung set TenHienThi='$tenhienthi' where MaNguoiDung=$manguoidung");
			$result=$this->querry();
			return $result;
		}
		function xoaNguoiDung($manguoidung)
		{
			$this->setQuerry("delete from nguoidung where MaNguoiDung=$manguoidung");
			$result=$this->querry();
			return $result;
		}
	}
?>